802E - Marmots (medium) - CodeForces Solution


math *2200

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
void func(){
int a[510];
int cnt=0,maxn=-2147483647,minn=2147483647;
for(int i=1;i<=250;++i){
cin>>a[i];
maxn=max(maxn,a[i]),minn=min(a[i],minn),cnt+=a[i];
}
double x=cnt/250.0;
int tot=0;
for(int i=1;i<=250;++i){
if(fabs(a[i]-x)<=x/2) ++tot;
}
if(tot/250.0>0.75) cout<<(int)round(x)<<"\n";
else cout<<(maxn+minn)/2<<"\n";
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;++i) func();

return 0;
}


Comments

Submit
0 Comments
More Questions

1088B - Ehab and subtraction
1270B - Interesting Subarray
478C - Table Decorations
1304C - Air Conditioner
1311C - Perform the Combo
1519C - Berland Regional
361A - Levko and Table
5E - Bindian Signalizing
687A - NP-Hard Problem
1542C - Strange Function
961E - Tufurama
129D - String
888A - Local Extrema
722B - Verse Pattern
278A - Circle Line
940A - Points on the line
1742C - Stripes
1742F - Smaller
1742B - Increasing
1742A - Sum
1742D - Coprime
390A - Inna and Alarm Clock
1398B - Substring Removal Game
1742G - Orray
416B - Art Union
962A - Equator
803B - Distances to Zero
291A - Spyke Talks
1742E - Scuza
1506D - Epic Transformation